<template>
  <div class="pdf-container">
    <embed 
      :src="pdfUrl" 
      type="application/pdf"
      width="100%"
      height="100%"
    />
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { SERVER_URL } from '../../config';

// 使用Set提升查找效率
const PDF_SET = new Set(['1-1', '1-2', '2', '3', '4-1', '4-2']);
const DEFAULT_INDEX = '0';

const route = useRoute();

// 更健壮的路由参数处理
const pdfUrl = computed(() => {
  const index = route.params.index?.toString() || DEFAULT_INDEX;
  return `${SERVER_URL}/static/pdf/${PDF_SET.has(index) ? index : DEFAULT_INDEX}.pdf`;
});
</script>

<style lang="scss" scoped>
.pdf-container {
  width: 100%;
  height: 100vh;
  display: flex;
  overflow: hidden;
  
  embed {
    flex: 1;
    min-height: 100vh;
    border: none;
  }
}
</style>